var a, t = require("../../00871763CDB955CF66E17F64E5D89F20.js"), s = getApp();

Page({
    data: {
        wenan: s.globalData.linksharewenan,
        maskHidden: !0,
        imagePath: "http://inews.gtimg.com/newsapp_ls/0/13392370753/0",
        data_src: "./img/1.jpg",
        pmwidth: "",
        pmheight: "",
        bigsrc: "http://inews.gtimg.com/newsapp_ls/0/13392370753/0",
        data_yangshi: [ {
            src: "http://inews.gtimg.com/newsapp_ls/0/13392370753/0"
        }, {
            src: "http://inews.gtimg.com/newsapp_ls/0/13391459157/0"
        }, {
            src: "http://inews.gtimg.com/newsapp_ls/0/13391460185/0"
        }, {
            src: "http://inews.gtimg.com/newsapp_ls/0/13392372151/0"
        }, {
            src: "http://inews.gtimg.com/newsapp_ls/0/13392372964/0"
        }, {
            src: "http://inews.gtimg.com/newsapp_ls/0/13392373929/0"
        } ],
        data_con: "您当前是信封模式，Ta点击信封即可查看",
        data_border: "5rpx solid rgba(0, 0, 255, 0.466)",
        currentIndex: 0
    },
    view_B_a1_tap: function(t) {
        var s = t.currentTarget.dataset.index;
        this.setData({
            currentIndex: s,
            bigsrc: t.currentTarget.dataset.src,
            data_src: ""
        }), 0 == t.currentTarget.dataset.index ? this.setData({
            data_src: "./img/1.jpg"
        }) : 1 == t.currentTarget.dataset.index ? this.setData({
            data_src: "./img/2.jpg"
        }) : 2 == t.currentTarget.dataset.index ? this.setData({
            data_src: "./img/3.jpg"
        }) : 3 == t.currentTarget.dataset.index ? this.setData({
            data_src: "./img/4.jpg"
        }) : 4 == t.currentTarget.dataset.index ? this.setData({
            data_src: "./img/5.jpg"
        }) : 5 == t.currentTarget.dataset.index && this.setData({
            data_src: "./img/6.jpg"
        }), this.draw(a, this.canvasToTempImage2);
    },
    onLoad: function(a) {
        var t = this;
        console.log(s.globalData.linksharewenan), wx.getSystemInfo({
            success: function(a) {
                console.log(a), t.setData({
                    pmwidth: a.windowWidth,
                    pmheight: a.windowHeight
                });
            }
        });
        var e = this.setCanvasSize(), n = s.globalData.linkplaceholder;
        this.createQrCode(n, "mycanvas", e.w, e.h), "(当前信封模式)" == s.globalData.linkmoshi ? this.setData({
            data_con: "您当前是信封模式，Ta点击信封即可查看"
        }) : this.setData({
            data_con: "您当前是密码模式，开屏密码是：" + s.globalData.linkpassword
        });
    },
    setCanvasSize: function() {
        var a = {};
        try {
            var t = wx.getSystemInfoSync().windowWidth / (750 / 686), s = t;
            a.w = t / 2.5, a.h = s;
        } catch (a) {
            console.log("获取设备信息失败" + a);
        }
        return a;
    },
    createQrCode: function(a, s, e, n) {
        t.api.draw(a, s, e, n, this, this.canvasToTempImage);
    },
    draw: function(a) {
        var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : function() {}, s = wx.createCanvasContext("mycanvas"), e = this, n = this.data.pmwidth / 1.25;
        wx.getImageInfo({
            src: e.data.data_src,
            success: function(i) {
                var c = "/" + i.path;
                s.drawImage(c, 0, 0, e.data.pmwidth, e.data.pmwidth / 1.6), s.drawImage(a, e.data.pmwidth / 1.7, e.data.pmwidth / 8.5, n, n / 1.625), 
                s.draw(!1, function() {
                    t();
                });
            }
        });
    },
    canvasToTempImage: function() {
        var t = this;
        wx.canvasToTempFilePath({
            canvasId: "mycanvas",
            success: function(s) {
                a = s.tempFilePath, console.log(a), t.draw(a, t.canvasToTempImage2);
            },
            fail: function(a) {
                console.log(a);
            }
        }, t);
    },
    canvasToTempImage2: function() {
        var a = this;
        wx.canvasToTempFilePath({
            canvasId: "mycanvas",
            success: function(t) {
                var s = t.tempFilePath;
                console.log(s), a.setData({
                    imagePath: s
                });
            },
            fail: function(a) {
                console.log(a);
            }
        }, a);
    },
    btn_a2_tap: function(a) {
        wx.setClipboardData({
            data: s.globalData.linkplaceholder,
            success: function(a) {
                wx.getClipboardData({
                    success: function(a) {
                        wx.showToast({
                            title: "已复制信封链接",
                            icon: "success"
                        });
                    }
                });
            }
        });
    },
    btn_a3_tap: function(a) {
        "(当前信封模式)" == s.globalData.linkmoshi ? wx.navigateTo({
            url: "/pages2/yulan/index"
        }) : wx.navigateTo({
            url: "/pages2/yulan2/index"
        });
    },
    btn_a4_tap: function(a) {
        wx.canvasToTempFilePath({
            canvasId: "mycanvas",
            success: function(a) {
                wx.saveImageToPhotosAlbum({
                    filePath: a.tempFilePath,
                    success: function() {
                        wx.showModal({
                            title: "保存成功",
                            content: "拿去发朋友圈或分享给好友吧",
                            showCancel: !1
                        });
                    }
                });
            }
        });
    },
    onShareAppMessage: function(a) {
        var t, e;
        return e = "(当前信封模式)" == s.globalData.linkmoshi ? "/pages2/yulan/index" : "/pages2/yulan2/index", 
        "./img/1.jpg" == this.data.data_src ? t = "http://inews.gtimg.com/newsapp_ls/0/13407373398/0" : "./img/2.jpg" == this.data.data_src ? t = "http://inews.gtimg.com/newsapp_ls/0/13407378813/0" : "./img/3.jpg" == this.data.data_src ? t = "http://inews.gtimg.com/newsapp_ls/0/13407379205/0" : "./img/4.jpg" == this.data.data_src ? t = "http://inews.gtimg.com/newsapp_ls/0/13407379463/0" : "./img/5.jpg" == this.data.data_src ? t = "http://inews.gtimg.com/newsapp_ls/0/13407379991/0" : "./img/6.jpg" == this.data.data_src && (t = "http://inews.gtimg.com/newsapp_ls/0/13407380487/0"), 
        {
            title: "给你写了一封信",
            path: e + "?wenan=" + s.globalData.linkwenan + "&musicurl=" + s.globalData.linkmusicurl + "&beijing=" + s.globalData.linkbeijing + "&peitu=" + s.globalData.linkpeitu + "&fontcolor=" + s.globalData.linkfontcolor + "&fontsize=" + s.globalData.linkfontsize + "&fontspeed=" + s.globalData.linkfontspeed + "&password=" + s.globalData.linkpassword,
            imageUrl: t,
            success: function(a) {
                wx.showToast({
                    title: "分享成功",
                    icon: "success",
                    duration: 2e3
                });
            },
            fail: function(a) {}
        };
    }
});